home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume21 / amd / part05 < prev    next >
Encoding:
Internet Message Format  |  1990-04-10  |  51.2 KB

  1. Subject:  v21i093:  An Automounter for NFS systems, Part05/13
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 2d5da923 05358962 b9646f3f 02868ace
  5.  
  6. Submitted-by: Jan-Simon Pendry <jsp@doc.ic.ac.uk>
  7. Posting-number: Volume 21, Issue 93
  8. Archive-name: amd/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 5 (of 13)."
  17. # Contents:  am.c amd-man amq_subr.c mk-amd-map.c mntfs.c nfs_prot.h
  18. #   nfs_prot.x
  19. # Wrapped by rsalz@papaya.bbn.com on Tue Apr 10 15:12:04 1990
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'am.c' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'am.c'\"
  23. else
  24. echo shar: Extracting \"'am.c'\" \(7064 characters\)
  25. sed "s/^X//" >'am.c' <<'END_OF_FILE'
  26. X/*
  27. X * $Id: am.c,v 5.1.1.1 90/01/11 16:58:29 jsp Exp Locker: jsp $
  28. X *
  29. X * Copyright (c) 1989 Jan-Simon Pendry
  30. X * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
  31. X * Copyright (c) 1989 The Regents of the University of California.
  32. X * All rights reserved.
  33. X *
  34. X * This code is derived from software contributed to Berkeley by
  35. X * Jan-Simon Pendry at Imperial College, London.
  36. X *
  37. X * Redistribution and use in source and binary forms are permitted
  38. X * provided that the above copyright notice and this paragraph are
  39. X * duplicated in all such forms and that any documentation,
  40. X * advertising materials, and other materials related to such
  41. X * distribution and use acknowledge that the software was developed
  42. X * by Imperial College of Science, Technology and Medicine, London, UK.
  43. X * The names of the College and University may not be used to endorse
  44. X * or promote products derived from this software without specific
  45. X * prior written permission.
  46. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  47. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  48. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  49. X *
  50. X *    %W% (Berkeley) %G%
  51. X */
  52. X
  53. X/*
  54. X * Automounter
  55. X */
  56. X
  57. X#include "am.h"
  58. X#include <sys/signal.h>
  59. X#include <netdb.h>
  60. X#include <sys/ioctl.h>
  61. X#include <fcntl.h>
  62. X#include <setjmp.h>
  63. X
  64. Xchar pid_fsname[16 + MAXHOSTNAMELEN];    /* "kiska.southseas.nz:(pid%d)" */
  65. Xchar *progname;                /* "amd" */
  66. Xchar *auto_dir = "/a";
  67. Xchar *hostdomain = "unknown.domain";
  68. Xchar hostname[MAXHOSTNAMELEN];        /* Hostname */
  69. Xchar hostd[2*MAXHOSTNAMELEN];        /* Host+domain */
  70. Xchar *op_sys = OS_REP;            /* Name of current op_sys */
  71. Xchar *arch = ARCH_REP;            /* Name of current architecture */
  72. Xchar *endian = ARCH_ENDIAN;        /* Big or Little endian */
  73. Xint foreground = 1;            /* This is the top-level server */
  74. Xint mypid;                /* Current process id */
  75. Xint immediate_abort;            /* Should close-down unmounts be retried */
  76. Xstruct in_addr myipaddr;        /* (An) IP address of this host */
  77. Xserv_state amd_state = Start;
  78. Xstruct amd_stats amd_stats;        /* Server statistics */
  79. Xtime_t do_mapc_reload = 0;        /* mapc_reload() call required? */
  80. Xjmp_buf select_intr;
  81. Xint select_intr_valid;
  82. Xint orig_umask;
  83. X
  84. X/*
  85. X * Signal handler:
  86. X * SIGINT - tells amd to do a full shutdown, including unmounting all filesystem.
  87. X * SIGTERM - tells amd to shutdown now.  Just unmounts the automount nodes.
  88. X */
  89. Xstatic void sigterm(sig)
  90. Xint sig;
  91. X{
  92. X#ifdef SYS5_SIGNALS
  93. X    signal(sig, sigterm);
  94. X#endif
  95. X
  96. X    switch (sig) {
  97. X    case SIGINT:
  98. X        immediate_abort = 15;
  99. X        break;
  100. X
  101. X    case SIGTERM:
  102. X        immediate_abort = -1;
  103. X        /* fall through... */
  104. X
  105. X    default:
  106. X        plog(XLOG_WARNING, "WARNING: automounter going down on signal %d", sig);
  107. X        break;
  108. X    }
  109. X    if (select_intr_valid)
  110. X        longjmp(select_intr, sig);
  111. X}
  112. X
  113. X/*
  114. X * Hook for cache reload.
  115. X * When a SIGHUP arrives it schedules a call to mapc_reload
  116. X */
  117. Xstatic void sighup(sig)
  118. Xint sig;
  119. X{
  120. X#ifdef SYS5_SIGNALS
  121. X    signal(sig, sighup);
  122. X#endif
  123. X
  124. X#ifdef DEBUG
  125. X    if (sig != SIGHUP)
  126. X        dlog("spurious call to sighup");
  127. X#endif
  128. X    /*
  129. X     * Force a reload by zero'ing the timer
  130. X     */
  131. X    if (amd_state == Run)
  132. X        do_mapc_reload = 0;
  133. X}
  134. X
  135. Xstatic void parent_exit(sig)
  136. Xint sig;
  137. X{
  138. X    exit(0);
  139. X}
  140. X
  141. Xstatic int daemon_mode(P_void)
  142. X{
  143. X    int bgpid = background();
  144. X
  145. X    if (bgpid != 0) {
  146. X        if (print_pid) {
  147. X            printf("%d\n", bgpid);
  148. X            fflush(stdout);
  149. X        }
  150. X        /*
  151. X         * Now wait for the automount points to
  152. X         * complete.
  153. X         */
  154. X        signal(SIGQUIT, parent_exit);
  155. X        for (;;)
  156. X            pause();
  157. X    }
  158. X
  159. X    /*
  160. X     * Pretend we are in the foreground again
  161. X     */
  162. X    foreground = 1;
  163. X#ifdef TIOCNOTTY
  164. X    {
  165. X        int t = open("/dev/tty", O_RDWR);
  166. X        if (t < 0) {
  167. X            if (errno != ENXIO)    /* not an error if already no controlling tty */
  168. X                plog(XLOG_WARNING, "Could not open controlling tty: %m");
  169. X        } else if (ioctl(t, TIOCNOTTY, 0) < 0) {
  170. X            plog(XLOG_WARNING, "Could not disassociate tty (TIOCNOTTY): %m");
  171. X        }
  172. X    }
  173. X#else
  174. X    (void) setpgrp();
  175. X#endif
  176. X
  177. X    return getppid();
  178. X}
  179. X
  180. Xmain(argc, argv)
  181. Xint argc;
  182. Xchar *argv[];
  183. X{
  184. X    struct hostent *hp, *gethostbyname();
  185. X    char *domdot;
  186. X    int ppid = 0;
  187. X    int error;
  188. X
  189. X    /*
  190. X     * Make sure some built-in assumptions are true before we start
  191. X     */
  192. X    assert(sizeof(nfscookie) >= sizeof (unsigned int));
  193. X    assert(sizeof(int) >= 4);
  194. X
  195. X    /*
  196. X     * Set processing status.
  197. X     */
  198. X    amd_state = Start;
  199. X
  200. X    /*
  201. X     * Get local machine name
  202. X     */
  203. X    if (gethostname(hostname, sizeof(hostname)) < 0) {
  204. X        plog(XLOG_FATAL, "gethostname: %m");
  205. X        going_down(1);
  206. X    }
  207. X    /*
  208. X     * Check it makes sense
  209. X     */
  210. X    if (!*hostname) {
  211. X        plog(XLOG_FATAL, "host name is not set");
  212. X        going_down(1);
  213. X    }
  214. X    /*
  215. X     * Partially initialise hostd[].  This
  216. X     * is completed in get_args().
  217. X     */
  218. X    if (domdot = strchr(hostname, '.')) {
  219. X        /*
  220. X         * Hostname already contains domainname.
  221. X         * Split out hostname and domainname
  222. X         * components
  223. X         */
  224. X        *domdot++ = '\0';
  225. X        hostdomain = domdot;
  226. X    }
  227. X    strcpy(hostd, hostname);
  228. X
  229. X    /*
  230. X     * Trap interrupts for shutdowns.
  231. X     */
  232. X    (void) signal(SIGINT, sigterm);
  233. X
  234. X    /*
  235. X     * Hangups tell us to reload the cache
  236. X     */
  237. X    (void) signal(SIGHUP, sighup);
  238. X
  239. X    /*
  240. X     * Trap Terminate so that we can shutdown gracefully (some chance)
  241. X     */
  242. X    (void) signal(SIGTERM, sigterm);
  243. X    /*
  244. X     * Trap Death-of-a-child.  These allow us to
  245. X     * pick up the exit status of backgrounded mounts.
  246. X     * See "sched.c".
  247. X     */
  248. X    (void) signal(SIGCHLD, sigchld);
  249. X
  250. X    /*
  251. X     * Initialise process id.  This is kept
  252. X     * cached since it is used for generating
  253. X     * and using file handles.
  254. X     */
  255. X    mypid = getpid();
  256. X
  257. X#ifdef notdef
  258. X/*
  259. X * XXX - Doing this plugs most of a memory leak in
  260. X * gethostbyname on SunOS 4.  I see no good reason
  261. X * why the host database needs to grab 1.5K of
  262. X * private data space...  However, for the moment,
  263. X * I will take its word that it is a _good thing_
  264. X * (jsp)
  265. X */
  266. X    (void) sethostent(0);
  267. X#endif
  268. X
  269. X    /*
  270. X     * Fix-up any umask problems.  Most systems default
  271. X     * to 002 which is not too convenient for our purposes
  272. X     */
  273. X    orig_umask = umask(0);
  274. X
  275. X    /*
  276. X     * Determine command-line arguments
  277. X     */
  278. X    get_args(argc, argv);
  279. X
  280. X    /*
  281. X     * Get our own IP address so that we
  282. X     * can mount the automounter.  There
  283. X     * is probably a better way of doing
  284. X     * this, but messing about with SIOCGCONF
  285. X     * seems to be heading towards the non-portable
  286. X     * arena.
  287. X     */
  288. X    hp = gethostbyname(hostname);
  289. X    if (!hp || hp->h_addrtype != AF_INET) {
  290. X        plog(XLOG_FATAL, "Can't determine IP address of this host (%s)", hostname);
  291. X        going_down(1);
  292. X    }
  293. X    myipaddr = *(struct in_addr *) hp->h_addr;
  294. X
  295. X    /*
  296. X     * Now check we are root.
  297. X     */
  298. X    if (geteuid() != 0) {
  299. X        plog(XLOG_FATAL, "Must be root to mount filesystems (euid = %d)", geteuid());
  300. X        going_down(1);
  301. X    }
  302. X
  303. X#ifdef HAS_YP_MAPS
  304. X    /*
  305. X     * If the domain was specified then bind it here
  306. X     * to circumvent any default bindings that may
  307. X     * be done in the C library.
  308. X     */
  309. X    if (domain && yp_bind(domain)) {
  310. X        plog(XLOG_FATAL, "Can't bind to domain \"%s\"", domain);
  311. X        going_down(1);
  312. X    }
  313. X#endif
  314. X
  315. X#ifdef DEBUG
  316. X    Debug(D_DAEMON)
  317. X#endif
  318. X    ppid = daemon_mode();
  319. X
  320. X    sprintf(pid_fsname, "%s:(pid%d)", hostname, mypid);
  321. X
  322. X    do_mapc_reload = clocktime() + ONE_HOUR;
  323. X
  324. X    /*
  325. X     * Register automounter with system
  326. X     */
  327. X    error = mount_automounter(ppid);
  328. X    if (error && ppid)
  329. X        kill(SIGALRM, ppid);
  330. X    going_down(error);
  331. X
  332. X    abort();
  333. X}
  334. END_OF_FILE
  335. if test 7064 -ne `wc -c <'am.c'`; then
  336.     echo shar: \"'am.c'\" unpacked with wrong size!
  337. fi
  338. # end of 'am.c'
  339. fi
  340. if test -f 'amd-man' -a "${1}" != "-c" ; then 
  341.   echo shar: Will not clobber existing file \"'amd-man'\"
  342. else
  343. echo shar: Extracting \"'amd-man'\" \(6057 characters\)
  344. sed "s/^X//" >'amd-man' <<'END_OF_FILE'
  345. X'\" $Id: amd-man,v 5.1 89/11/17 18:23:51 jsp Exp Locker: jsp $
  346. X'\" Copyright (c) 1989 Jan-Simon Pendry
  347. X'\" Copyright (c) 1989 Imperial College of Science, Technology & Medicine
  348. X'\" Copyright (c) 1989 The Regents of the University of California.
  349. X'\" All rights reserved.
  350. X'\"
  351. X'\" This code is derived from software contributed to Berkeley by
  352. X'\" Jan-Simon Pendry at Imperial College, London.
  353. X'\"
  354. X'\" Redistribution and use in source and binary forms are permitted
  355. X'\" provided that the above copyright notice and this paragraph are
  356. X'\" duplicated in all such forms and that any documentation,
  357. X'\" advertising materials, and other materials related to such
  358. X'\" distribution and use acknowledge that the software was developed
  359. X'\" by Imperial College of Science, Technology and Medicine, London, UK.
  360. X'\" The names of the College and University may not be used to endorse
  361. X'\" or promote products derived from this software without specific
  362. X'\" prior written permission.
  363. X'\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  364. X'\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  365. X'\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  366. X'\"
  367. X'\"    %W% (Berkeley) %G%
  368. X'\"
  369. X.TH AMD 8 "3 November 1989"
  370. X.SH NAME
  371. Xamd \- automatically mount file systems
  372. X.SH SYNOPSIS
  373. X.B amd
  374. X[
  375. X.B \-nprv
  376. X] [
  377. X.BI \-a " mount_point"
  378. X] [
  379. X.BI \-c " duration"
  380. X] [
  381. X.BI \-d " domain"
  382. X] [
  383. X.BI \-k " kernel-arch"
  384. X] [
  385. X.BI \-l " logfile"
  386. X] [
  387. X.BI \-t " interval.interval"
  388. X] [
  389. X.BI \-w " interval"
  390. X] [
  391. X.BI \-x " log-option"
  392. X] [
  393. X.BI \-y " YP-domain"
  394. X] [
  395. X.BI \-C " cluster-name"
  396. X] [
  397. X.BI \-D " option"
  398. X]
  399. X[
  400. X.I directory
  401. X.I mapname
  402. X.RI [ " \-map-options " ]
  403. X] .\|.\|.
  404. X.SH DESCRIPTION
  405. X.B Amd
  406. Xis a daemon that automatically mounts filesystems
  407. Xwhenever a file or directory
  408. Xwithin that filesystem is accessed.
  409. XFilesystems are automatically unmounted when they
  410. Xappear to have become quiescent.
  411. X.LP
  412. X.B Amd
  413. Xhas been designed as a value-added replacement
  414. Xfor the SunOS 4
  415. X.IR automount (8)
  416. Xprogram.
  417. XConsiderable design effort has been expended in making
  418. X.B amd
  419. Xrobust in the face of
  420. X.SM NFS
  421. Xservers going down.
  422. X.B Amd
  423. Xoperates by attaching itself as an
  424. X.SM NFS
  425. Xserver to each of the specified
  426. X.IB directories .
  427. XLookups within the specified directories
  428. Xare handled by
  429. X.BR amd ,
  430. Xwhich uses the map contained in
  431. X.I mapname
  432. Xto determine how to resolve the lookup.
  433. XGenerally, this will be a host name, some filesystem information
  434. Xand some mount options for the given filesystem.
  435. X.SH OPTIONS
  436. X.TP
  437. X.B \-n
  438. XNormalize hostnames.
  439. XThe name refered to by ${rhost} are normalized relative to the
  440. Xhost database before being used.  The effect is to translate
  441. Xaliases into ``official'' names.
  442. X.TP
  443. X.B \-p
  444. XPrint PID.
  445. XOutputs the process-id of
  446. X.B amd
  447. Xto standard output where it can be saved into a file.
  448. X.TP
  449. X.B \-r
  450. XRestart existing mounts.
  451. X.B Amd
  452. Xwill scan the mount file table to determine which filesystems
  453. Xare currently mounted.  Whenever one of these would have
  454. Xbeen auto-mounted,
  455. X.B amd
  456. X.I inherits
  457. Xit.
  458. X.TP
  459. X.B \-v
  460. XVersion.  Displays version and configuration information on standard error.
  461. XIf you send a bug report, this should be used to determine
  462. Xwhich version of
  463. X.B amd
  464. Xyou are using.
  465. X.TP
  466. X.BI \-a " temporary-directory"
  467. XSpecify an alternative location for the real mount points.
  468. XThe default is
  469. X.BR /a .
  470. X.TP
  471. X.BI \-c " duration"
  472. XSpecify a
  473. X.IR duration ,
  474. Xin seconds, that a looked up name remains
  475. Xcached when not in use.  The default is 5 minutes.
  476. X.TP
  477. X.BI \-d " domain"
  478. XSpecify the local domain name.  If this option is not
  479. Xgiven the domain name is determined from the hostname.
  480. X.TP
  481. X.BI \-k " kernel-arch"
  482. XSpecifies the kernel architecture.  This is used solely
  483. Xto set the ${karch} selector.
  484. X.TP
  485. X.BI \-l " logfile"
  486. XSpecify a logfile in which to record mount and unmount events.
  487. XIf
  488. X.I logfile
  489. Xis the string
  490. X.B syslog
  491. Xthen the log messages will be sent to the system log daemon by
  492. X.IR syslog (3).
  493. XThis is only available on certain systems (e.g.
  494. X.I not
  495. X.SM HP-UX
  496. Xand early versions of Ultrix).
  497. X.TP
  498. X.BI \-t " interval.interval"
  499. XSpecify the
  500. X.IR interval ,
  501. Xin tenths of a second, between NFS/RPC/UDP retries.
  502. XThe default is 0.8 seconds.
  503. XThe second values alters the restransmit counter.
  504. XUseful defaults are supplied if either or both
  505. Xvalues are missing.
  506. X.TP
  507. X.BI \-w " interval"
  508. XSpecify an
  509. X.IR interval ,
  510. Xin seconds, between attempts to dismount
  511. Xfilesystems that have exceeded their cached times.
  512. XThe default is 2 minutes.
  513. X.TP
  514. X.BI \-y " domain"
  515. XSpecify an alternative YP domain from which to fetch the YP maps.
  516. XThe default is the system domain name.
  517. X.TP
  518. X.BI \-x " options"
  519. XSpecify run-time logging options.  The options are a comma separated
  520. Xlist chosen from: fatal, error, user, warn, info, all.
  521. X.TP
  522. X.BI \-D " option"
  523. XSelect from a variety of debug options.  Prefixing an
  524. Xoption with the strings
  525. X.B no
  526. Xreverses the effect of that option.  Options are cumulative.
  527. XThe most useful option is
  528. X.BR all .
  529. XSince
  530. X.I \-D
  531. Xis only used for debugging other options are not documented here:
  532. Xthe current supported set of options is listed by the \-v option
  533. Xand a fuller description is available in the program source.
  534. X.SH FILES
  535. X.PD 0
  536. X.TP 5
  537. X.B /a
  538. Xdirectory under which filesystems are dynamically mounted
  539. X.PD
  540. X.SH CAVEATS
  541. XSome care may be required when creating a mount map.
  542. X.LP
  543. XSymbolic links on an NFS filesystem are incredibly inefficient.
  544. XTheir interpolations are not cached by the kernel and each time a symlink is
  545. Xencountered during a
  546. X.I lookuppn
  547. Xtranslation it costs an RPC call to the NFS server.
  548. XIt would appear that a large improvement in real-time
  549. Xperformance could be gained by adding a cache somewhere.
  550. XReplacing symlinks with a suitable incarnation of the auto-mounter
  551. Xresults in a large real-time speedup, but also causes a large
  552. Xnumber of process context switches.
  553. X.LP
  554. XA weird imagination is most useful to gain full advantage of all
  555. Xthe features.
  556. X.SH "SEE ALSO"
  557. X.BR domainname (1),
  558. X.BR hostname (1),
  559. X.BR automount (8),
  560. X.BR mount (8),
  561. X.BR umount (8),
  562. X.BR mtab (5),
  563. X.LP
  564. X.I "Amd \- An Automounter"
  565. X.SH AUTHOR
  566. XJan-Simon Pendry <jsp@doc.ic.ac.uk>, Department of Computing, Imperial College, London, UK.
  567. END_OF_FILE
  568. if test 6057 -ne `wc -c <'amd-man'`; then
  569.     echo shar: \"'amd-man'\" unpacked with wrong size!
  570. fi
  571. # end of 'amd-man'
  572. fi
  573. if test -f 'amq_subr.c' -a "${1}" != "-c" ; then 
  574.   echo shar: Will not clobber existing file \"'amq_subr.c'\"
  575. else
  576. echo shar: Extracting \"'amq_subr.c'\" \(7290 characters\)
  577. sed "s/^X//" >'amq_subr.c' <<'END_OF_FILE'
  578. X/*
  579. X * $Id: amq_subr.c,v 5.1.1.1 90/01/11 17:03:40 jsp Exp Locker: jsp $
  580. X *
  581. X * Copyright (c) 1990 Jan-Simon Pendry
  582. X * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  583. X * Copyright (c) 1990 The Regents of the University of California.
  584. X * All rights reserved.
  585. X *
  586. X * This code is derived from software contributed to Berkeley by
  587. X * Jan-Simon Pendry at Imperial College, London.
  588. X *
  589. X * Redistribution and use in source and binary forms are permitted
  590. X * provided that the above copyright notice and this paragraph are
  591. X * duplicated in all such forms and that any documentation,
  592. X * advertising materials, and other materials related to such
  593. X * distribution and use acknowledge that the software was developed
  594. X * by Imperial College of Science, Technology and Medicine, London, UK.
  595. X * The names of the College and University may not be used to endorse
  596. X * or promote products derived from this software without specific
  597. X * prior written permission.
  598. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  599. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  600. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  601. X *
  602. X *    %W% (Berkeley) %G%
  603. X */
  604. X/*
  605. X * Auxilliary routines for amq tool
  606. X */
  607. X
  608. X#include "am.h"
  609. X#include "amq.h"
  610. X
  611. X#include <sys/param.h>
  612. X
  613. X/*ARGSUSED*/
  614. Xvoidp
  615. Xamqproc_null_1(argp, rqstp)
  616. Xvoidp argp;
  617. Xstruct svc_req *rqstp;
  618. X{
  619. X    static char res;
  620. X
  621. X    return (voidp) &res;
  622. X}
  623. X
  624. X/*
  625. X * Return a sub-tree of mounts
  626. X */
  627. X/*ARGSUSED*/
  628. Xamq_mount_tree_p *
  629. Xamqproc_mnttree_1(argp, rqstp)
  630. Xvoidp argp;
  631. Xstruct svc_req *rqstp;
  632. X{
  633. X    static am_node *mp;
  634. X    mp = find_ap(*(char **) argp);
  635. X    return (amq_mount_tree_p *) ∓
  636. X}
  637. X
  638. X/*
  639. X * Unmount a single node
  640. X */
  641. X/*ARGSUSED*/
  642. Xvoidp
  643. Xamqproc_umnt_1(argp, rqstp)
  644. Xvoidp argp;
  645. Xstruct svc_req *rqstp;
  646. X{
  647. X    static char res;
  648. X    am_node *mp = find_ap(*(char **) argp);
  649. X    if (mp)
  650. X        forcibly_timeout_mp(mp);
  651. X
  652. X    return (voidp) &res;
  653. X}
  654. X
  655. X/*
  656. X * Return global statistics
  657. X */
  658. X/*ARGSUSED*/
  659. Xamq_mount_stats *
  660. Xamqproc_stats_1(argp, rqstp)
  661. Xvoidp argp;
  662. Xstruct svc_req *rqstp;
  663. X{
  664. X    return (amq_mount_stats *) &amd_stats;
  665. X}
  666. X
  667. X/*
  668. X * Return the entire tree of mount nodes
  669. X */
  670. X/*ARGSUSED*/
  671. Xamq_mount_tree_list *
  672. Xamqproc_export_1(argp, rqstp)
  673. Xvoidp argp;
  674. Xstruct svc_req *rqstp;
  675. X{
  676. X    static amq_mount_tree_list aml;
  677. X
  678. X#ifdef oldcode
  679. X    static am_node **mvec;
  680. X    int i;
  681. X    int n = 0;
  682. X
  683. X    mvec = (struct am_node **)
  684. X        xrealloc(mvec, (1+last_used_map) * sizeof(am_node *));
  685. X    for (i = last_used_map; i >= 0; --i) {
  686. X        am_node *mp = exported_ap[i];
  687. X        if (mp && (mp->am_flags & AMF_ROOT))
  688. X            mvec[n++] = mp;
  689. X    }
  690. X
  691. X    aml.amq_mount_tree_list_val = (amq_mount_tree_p *) mvec;
  692. X    aml.amq_mount_tree_list_len = n;
  693. X#else
  694. X    aml.amq_mount_tree_list_val = (amq_mount_tree_p *) &exported_ap[0];
  695. X    aml.amq_mount_tree_list_len = 1;    /* XXX */
  696. X#endif
  697. X    return &aml;
  698. X}
  699. X
  700. Xint *
  701. Xamqproc_setopt_1(argp, rqstp)
  702. Xvoidp argp;
  703. Xstruct svc_req *rqstp;
  704. X{
  705. X    static int rc;
  706. X
  707. X    amq_setopt *opt = (amq_setopt *) argp;
  708. X
  709. X    rc = 0;
  710. X    switch (opt->as_opt) {
  711. X    case AMOPT_DEBUG:
  712. X#ifdef DEBUG
  713. X        if (debug_option(opt->as_str))
  714. X            rc = EINVAL;
  715. X#else
  716. X        rc = EINVAL;
  717. X#endif
  718. X        break;
  719. X
  720. X    case AMOPT_LOGFILE:
  721. X#ifdef not_yet
  722. X        if (switch_to_logfile(opt->as_str))
  723. X            rc = EINVAL;
  724. X#else
  725. X        rc = EACCES;
  726. X#endif
  727. X        break;
  728. X
  729. X    case AMOPT_XLOG:
  730. X        if (switch_option(opt->as_str))
  731. X            rc = EINVAL;
  732. X        break;
  733. X
  734. X    case AMOPT_FLUSHMAPC:
  735. X        if (amd_state == Run) {
  736. X            plog(XLOG_INFO, "amq says flush cache");
  737. X            do_mapc_reload = 0;
  738. X        }
  739. X        break;
  740. X    }
  741. X    return &rc;
  742. X}
  743. X
  744. Xamq_mount_info_list *
  745. Xamqproc_getmntfs_1(argp, rqstp)
  746. Xvoidp argp;
  747. Xstruct svc_req *rqstp;
  748. X{
  749. Xextern qelem mfhead;
  750. X    return (amq_mount_info_list *) &mfhead;    /* XXX */
  751. X}
  752. X
  753. X/*
  754. X * XDR routines.
  755. X */
  756. Xbool_t
  757. Xxdr_amq_string(xdrs, objp)
  758. X    XDR *xdrs;
  759. X    amq_string *objp;
  760. X{
  761. X    if (!xdr_string(xdrs, objp, AMQ_STRLEN)) {
  762. X        return (FALSE);
  763. X    }
  764. X    return (TRUE);
  765. X}
  766. X
  767. Xbool_t
  768. Xxdr_amq_setopt(xdrs, objp)
  769. X    XDR *xdrs;
  770. X    amq_setopt *objp;
  771. X{
  772. X    if (!xdr_enum(xdrs, (enum_t *)&objp->as_opt)) {
  773. X        return (FALSE);
  774. X    }
  775. X    if (!xdr_string(xdrs, &objp->as_str, AMQ_STRLEN)) {
  776. X        return (FALSE);
  777. X    }
  778. X    return (TRUE);
  779. X}
  780. X
  781. X/*
  782. X * More XDR routines  - Should be used for OUTPUT ONLY.
  783. X */
  784. Xbool_t
  785. Xxdr_amq_mount_tree(xdrs, objp)
  786. X    XDR *xdrs;
  787. X    amq_mount_tree *objp;
  788. X{
  789. X    am_node *mp = (am_node *) objp;
  790. X
  791. X    if (!xdr_amq_string(xdrs, &mp->am_mnt->mf_info)) {
  792. X        return (FALSE);
  793. X    }
  794. X    if (!xdr_amq_string(xdrs, &mp->am_path)) {
  795. X        return (FALSE);
  796. X    }
  797. X    if (!xdr_amq_string(xdrs, mp->am_link ? &mp->am_link : &mp->am_mnt->mf_mount)) {
  798. X        return (FALSE);
  799. X    }
  800. X    if (!xdr_amq_string(xdrs, &mp->am_mnt->mf_ops->fs_type)) {
  801. X        return (FALSE);
  802. X    }
  803. X    if (!xdr_long(xdrs, &mp->am_stats.s_mtime)) {
  804. X        return (FALSE);
  805. X    }
  806. X    if (!xdr_u_short(xdrs, &mp->am_stats.s_uid)) {
  807. X        return (FALSE);
  808. X    }
  809. X    if (!xdr_int(xdrs, &mp->am_stats.s_getattr)) {
  810. X        return (FALSE);
  811. X    }
  812. X    if (!xdr_int(xdrs, &mp->am_stats.s_lookup)) {
  813. X        return (FALSE);
  814. X    }
  815. X    if (!xdr_int(xdrs, &mp->am_stats.s_readdir)) {
  816. X        return (FALSE);
  817. X    }
  818. X    if (!xdr_int(xdrs, &mp->am_stats.s_readlink)) {
  819. X        return (FALSE);
  820. X    }
  821. X    if (!xdr_int(xdrs, &mp->am_stats.s_statfs)) {
  822. X        return (FALSE);
  823. X    }
  824. X    if (!xdr_pointer(xdrs, (char **)&mp->am_osib, sizeof(amq_mount_tree), xdr_amq_mount_tree)) {
  825. X        return (FALSE);
  826. X    }
  827. X    if (!xdr_pointer(xdrs, (char **)&mp->am_child, sizeof(amq_mount_tree), xdr_amq_mount_tree)) {
  828. X        return (FALSE);
  829. X    }
  830. X    return (TRUE);
  831. X}
  832. X
  833. Xbool_t
  834. Xxdr_amq_mount_tree_p(xdrs, objp)
  835. X    XDR *xdrs;
  836. X    amq_mount_tree_p *objp;
  837. X{
  838. X    if (!xdr_pointer(xdrs, (char **)objp, sizeof(amq_mount_tree), xdr_amq_mount_tree)) {
  839. X        return (FALSE);
  840. X    }
  841. X    return (TRUE);
  842. X}
  843. X
  844. X
  845. Xbool_t
  846. Xxdr_amq_mount_stats(xdrs, objp)
  847. X    XDR *xdrs;
  848. X    amq_mount_stats *objp;
  849. X{
  850. X    if (!xdr_int(xdrs, &objp->as_drops)) {
  851. X        return (FALSE);
  852. X    }
  853. X    if (!xdr_int(xdrs, &objp->as_stale)) {
  854. X        return (FALSE);
  855. X    }
  856. X    if (!xdr_int(xdrs, &objp->as_mok)) {
  857. X        return (FALSE);
  858. X    }
  859. X    if (!xdr_int(xdrs, &objp->as_merr)) {
  860. X        return (FALSE);
  861. X    }
  862. X    if (!xdr_int(xdrs, &objp->as_uerr)) {
  863. X        return (FALSE);
  864. X    }
  865. X    return (TRUE);
  866. X}
  867. X
  868. X
  869. Xbool_t
  870. Xxdr_amq_mount_tree_list(xdrs, objp)
  871. X    XDR *xdrs;
  872. X    amq_mount_tree_list *objp;
  873. X{
  874. X     if (!xdr_array(xdrs, (char **)&objp->amq_mount_tree_list_val, (u_int *)&objp->amq_mount_tree_list_len, ~0, sizeof(amq_mount_tree_p), xdr_amq_mount_tree_p)) {
  875. X        return (FALSE);
  876. X    }
  877. X    return (TRUE);
  878. X}
  879. X
  880. Xxdr_amq_mount_info_qelem(xdrs, qhead)
  881. X    XDR *xdrs;
  882. X    qelem *qhead;
  883. X{
  884. X    /*
  885. X     * Compute length of list
  886. X     */
  887. X    mntfs *mf;
  888. X    u_int len = 0;
  889. X    for (mf = LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) {
  890. X        if (!(mf->mf_ops->fs_flags & FS_AMQINFO))
  891. X            continue;
  892. X        len++;
  893. X    }
  894. X    xdr_u_int(xdrs, &len);
  895. X
  896. X    /*
  897. X     * Send individual data items
  898. X     */
  899. X    for (mf = LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) {
  900. X        int up;
  901. X        if (!(mf->mf_ops->fs_flags & FS_AMQINFO))
  902. X            continue;
  903. X
  904. X        if (!xdr_amq_string(xdrs, &mf->mf_ops->fs_type)) {
  905. X            return (FALSE);
  906. X        }
  907. X        if (!xdr_amq_string(xdrs, &mf->mf_mount)) {
  908. X            return (FALSE);
  909. X        }
  910. X        if (!xdr_amq_string(xdrs, &mf->mf_info)) {
  911. X            return (FALSE);
  912. X        }
  913. X        if (!xdr_amq_string(xdrs, &mf->mf_server->fs_host)) {
  914. X            return (FALSE);
  915. X        }
  916. X        if (!xdr_int(xdrs, &mf->mf_error)) {
  917. X            return (FALSE);
  918. X        }
  919. X        if (!xdr_int(xdrs, &mf->mf_refc)) {
  920. X            return (FALSE);
  921. X        }
  922. X        if (mf->mf_server->fs_flags & FSF_ERROR)
  923. X            up = 0;
  924. X        else switch (mf->mf_server->fs_flags & (FSF_DOWN|FSF_VALID)) {
  925. X        case FSF_DOWN|FSF_VALID: up = 0; break;
  926. X        case FSF_VALID: up = 1; break;
  927. X        default: up = -1; break;
  928. X        }
  929. X        if (!xdr_int(xdrs, &up)) {
  930. X            return (FALSE);
  931. X        }
  932. X    }
  933. X    return (TRUE);
  934. X}
  935. END_OF_FILE
  936. if test 7290 -ne `wc -c <'amq_subr.c'`; then
  937.     echo shar: \"'amq_subr.c'\" unpacked with wrong size!
  938. fi
  939. # end of 'amq_subr.c'
  940. fi
  941. if test -f 'mk-amd-map.c' -a "${1}" != "-c" ; then 
  942.   echo shar: Will not clobber existing file \"'mk-amd-map.c'\"
  943. else
  944. echo shar: Extracting \"'mk-amd-map.c'\" \(6603 characters\)
  945. sed "s/^X//" >'mk-amd-map.c' <<'END_OF_FILE'
  946. X/*
  947. X * $Id: mk-amd-map.c,v 5.1.1.2 90/01/11 17:09:31 jsp Exp Locker: jsp $
  948. X *
  949. X * Copyright (c) 1990 Jan-Simon Pendry
  950. X * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  951. X * Copyright (c) 1990 The Regents of the University of California.
  952. X * All rights reserved.
  953. X *
  954. X * This code is derived from software contributed to Berkeley by
  955. X * Jan-Simon Pendry at Imperial College, London.
  956. X *
  957. X * Redistribution and use in source and binary forms are permitted
  958. X * provided that the above copyright notice and this paragraph are
  959. X * duplicated in all such forms and that any documentation,
  960. X * advertising materials, and other materials related to such
  961. X * distribution and use acknowledge that the software was developed
  962. X * by Imperial College of Science, Technology and Medicine, London, UK.
  963. X * The names of the College and University may not be used to endorse
  964. X * or promote products derived from this software without specific
  965. X * prior written permission.
  966. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  967. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  968. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  969. X */
  970. X
  971. X/*
  972. X * Convert a file map into an ndbm map
  973. X */
  974. X
  975. X#ifndef lint
  976. Xchar copyright[] = "\
  977. X@(#)Copyright (c) 1990 Jan-Simon Pendry\n\
  978. X@(#)Copyright (c) 1990 Imperial College of Science, Technology & Medicine\n\
  979. X@(#)Copyright (c) 1990 The Regents of the University of California.\n\
  980. X@(#)All rights reserved.\n";
  981. X#endif /* not lint */
  982. X
  983. X#ifndef lint
  984. Xstatic char rcsid[] = "$Id: mk-amd-map.c,v 5.1.1.2 90/01/11 17:09:31 jsp Exp Locker: jsp $";
  985. Xstatic char sccsid[] = "%W% (Berkeley) %G%";
  986. X#endif /* not lint */
  987. X
  988. X#include "am.h"
  989. X
  990. X#ifdef OS_HAS_GDBM
  991. X#define HAS_DATABASE
  992. X#include "gdbm.h"
  993. X#endif
  994. X
  995. X#ifndef HAS_DATABASE
  996. X#ifdef OS_HAS_NDBM
  997. X#define HAS_DATABASE
  998. X#define    USE_NDBM
  999. X#include <ndbm.h>
  1000. X
  1001. X#define create_database(name) dbm_open(name, O_RDWR|O_CREAT, 0444)
  1002. X
  1003. Xstatic int store_data(db, k, v)
  1004. Xvoidp db;
  1005. Xchar *k, *v;
  1006. X{
  1007. X    datum key, val;
  1008. X
  1009. X    key.dptr = k; val.dptr = v;
  1010. X    key.dsize = strlen(k) + 1;
  1011. X    val.dsize = strlen(v) + 1;
  1012. X    return dbm_store((DBM *) db, key, val, DBM_INSERT);
  1013. X}
  1014. X
  1015. X#endif /* OS_HAS_NDBM */
  1016. X#endif /* !OS_HAS_DATABASE */
  1017. X
  1018. X#ifdef HAS_DATABASE
  1019. X#include <fcntl.h>
  1020. X#include <ctype.h>
  1021. X
  1022. Xstatic int read_line(buf, size, fp)
  1023. Xchar *buf;
  1024. Xint size;
  1025. XFILE *fp;
  1026. X{
  1027. X    int done = 0;
  1028. X
  1029. X    do {
  1030. X        while (fgets(buf, size, fp)) {
  1031. X            int len = strlen(buf);
  1032. X            done += len;
  1033. X            if (len > 1 && buf[len-2] == '\\' &&
  1034. X                    buf[len-1] == '\n') {
  1035. X                int ch;
  1036. X                buf += len - 2;
  1037. X                size -= len - 2;
  1038. X                /*
  1039. X                 * Skip leading white space on next line
  1040. X                 */
  1041. X                while ((ch = getc(fp)) != EOF &&
  1042. X                    isascii(ch) && isspace(ch))
  1043. X                        ;
  1044. X                (void) ungetc(ch, fp);
  1045. X            } else {
  1046. X                return done;
  1047. X            }
  1048. X        }
  1049. X    } while (size > 0 && !feof(fp));
  1050. X
  1051. X    return done;
  1052. X}
  1053. X
  1054. X/*
  1055. X * Read through a map
  1056. X */
  1057. Xstatic int read_file(fp, map, db)
  1058. XFILE *fp;
  1059. Xchar *map;
  1060. Xvoidp db;
  1061. X{
  1062. X    char key_val[2048];
  1063. X    int chuck = 0;
  1064. X    int line_no = 0;
  1065. X    int errs = 0;
  1066. X
  1067. X    while (read_line(key_val, sizeof(key_val), fp)) {
  1068. X        char *kp;
  1069. X        char *cp;
  1070. X        char *hash;
  1071. X        int len = strlen(key_val);
  1072. X        line_no++;
  1073. X
  1074. X        /*
  1075. X         * Make sure we got the whole line
  1076. X         */
  1077. X        if (key_val[len-1] != '\n') {
  1078. X            fprintf(stderr, "line %d in \"%s\" is too long", line_no, map);
  1079. X            chuck = 1;
  1080. X        } else {
  1081. X            key_val[len-1] = '\0';
  1082. X        }
  1083. X
  1084. X        /*
  1085. X         * Strip comments
  1086. X         */
  1087. X        hash = strchr(key_val, '#');
  1088. X        if (hash)
  1089. X            *hash = '\0';
  1090. X
  1091. X        /*
  1092. X         * Find start of key
  1093. X         */
  1094. X        for (kp = key_val; *kp && isascii(*kp) && isspace(*kp); kp++)
  1095. X            ;
  1096. X
  1097. X        /*
  1098. X         * Ignore blank lines
  1099. X         */
  1100. X        if (!*kp)
  1101. X            goto again;
  1102. X
  1103. X        /*
  1104. X         * Find end of key
  1105. X         */
  1106. X        for (cp = kp; *cp&&(!isascii(*cp)||!isspace(*cp)); cp++)
  1107. X            ;
  1108. X
  1109. X        /*
  1110. X         * Check whether key matches, or whether
  1111. X         * the entry is a wildcard entry.
  1112. X         */
  1113. X        if (*cp)
  1114. X            *cp++ = '\0';
  1115. X        while (*cp && isascii(*cp) && isspace(*cp))
  1116. X            cp++;
  1117. X        if (*kp == '+') {
  1118. X            fprintf(stderr, "Can't interpolate %s\n", kp);
  1119. X            errs++;
  1120. X        } else if (*cp) {
  1121. X#ifdef DEBUG
  1122. X            printf("%s\t%s\n", kp, cp);
  1123. X#endif
  1124. X            if (store_data(db, kp, cp) < 0) {
  1125. X                fprintf(stderr, "Could store %s -> %s\n", kp, cp);
  1126. X                errs++;
  1127. X            }
  1128. X        } else {
  1129. X            fprintf(stderr, "%s: line %d has no value field", map, line_no);
  1130. X            errs++;
  1131. X        }
  1132. X
  1133. Xagain:
  1134. X        /*
  1135. X         * If the last read didn't get a whole line then
  1136. X         * throw away the remainder before continuing...
  1137. X         */
  1138. X        if (chuck) {
  1139. X            while (fgets(key_val, sizeof(key_val), fp) &&
  1140. X                !strchr(key_val, '\n'))
  1141. X                    ;
  1142. X            chuck = 0;
  1143. X        }
  1144. X    }
  1145. X    return errs;
  1146. X}
  1147. X
  1148. Xstatic int remove(f)
  1149. Xchar *f;
  1150. X{
  1151. X    if (unlink(f) < 0 && errno != ENOENT)
  1152. X        return -1;
  1153. X    return 0;
  1154. X}
  1155. X
  1156. Xmain(argc, argv)
  1157. Xint argc;
  1158. Xchar *argv[];
  1159. X{
  1160. X    FILE *mapf;
  1161. X    char *map;
  1162. X    int rc = 0;
  1163. X    DBM *mapd;
  1164. X    char *maptmp = "dbmXXXXXX";
  1165. X    char maptpag[16], maptdir[16];
  1166. X    char *mappag, *mapdir;
  1167. X    int len;
  1168. X    char *sl;
  1169. X
  1170. X    if (argc != 2) {
  1171. X        fputs("Usage: mk-amd-map file-map\n", stderr);
  1172. X        exit(1);
  1173. X    }
  1174. X
  1175. X    map = argv[1];
  1176. X    sl = strrchr(map, '/');
  1177. X    if (sl) {
  1178. X        *sl = '\0';
  1179. X        if (chdir(map) < 0) {
  1180. X            fputs("Can't chdir to ", stderr);
  1181. X            perror(map);
  1182. X            exit(1);
  1183. X        }
  1184. X        map = sl + 1;
  1185. X    }
  1186. X#ifdef USE_NDBM
  1187. X    len = strlen(map);
  1188. X    mappag = (char *) malloc(len + 5);
  1189. X    mapdir = (char *) malloc(len + 5);
  1190. X    if (!mappag || !mapdir) {
  1191. X        perror("malloc");
  1192. X        exit(1);
  1193. X    }
  1194. X    mktemp(maptmp);
  1195. X    sprintf(maptpag, "%s.pag", maptmp);
  1196. X    sprintf(maptdir, "%s.dir", maptmp);
  1197. X    if (remove(maptpag) < 0 || remove(maptdir) < 0) {
  1198. X        fprintf(stderr, "Can't remove existing temporary files; %s and", maptpag);
  1199. X        perror(maptdir);
  1200. X        exit(1);
  1201. X    }
  1202. X#endif
  1203. X    mapf =  fopen(map, "r");
  1204. X    if (mapf)
  1205. X        mapd = create_database(maptmp);
  1206. X    else
  1207. X        mapd = 0;
  1208. X#ifndef DEBUG
  1209. X    signal(SIGINT, SIG_IGN);
  1210. X#endif
  1211. X    if (mapd) {
  1212. X        int error = read_file(mapf, map, mapd);
  1213. X        (void) fclose(mapf);
  1214. X        if (error) {
  1215. X            fprintf(stderr, "Error creating ndbm map for %s\n", map);
  1216. X            rc = 1;
  1217. X        }
  1218. X#ifdef USE_NDBM
  1219. X        sprintf(mappag, "%s.pag", map);
  1220. X        sprintf(mapdir, "%s.dir", map);
  1221. X        if (rename(maptpag, mappag) < 0) {
  1222. X            fprintf(stderr, "Couldn't rename %s to ", maptpag);
  1223. X            perror(mappag);
  1224. X            /* Throw away the temporary map */
  1225. X            unlink(maptpag);
  1226. X            unlink(maptdir);
  1227. X            rc = 1;
  1228. X        } else if (rename(maptdir, mapdir) < 0) {
  1229. X            fprintf(stderr, "Couldn't rename %s to ", maptdir);
  1230. X            perror(mapdir);
  1231. X            /* Put the .pag file back */
  1232. X            rename(mappag, maptpag);
  1233. X            /* Throw away remaining part of original map */
  1234. X            unlink(mapdir);
  1235. X            fprintf(stderr, "WARNING: existing map \"%s.{dir,pag}\" destroyed\n", map);
  1236. X            rc = 1;
  1237. X        }
  1238. X#endif
  1239. X    } else {
  1240. X#ifdef USE_NDBM
  1241. X        fprintf(stderr, "Can't open \"%s.{dir,pag}\" for ", map);
  1242. X#endif
  1243. X        perror("writing");
  1244. X        rc = 1;
  1245. X    }
  1246. X    exit(rc);
  1247. X}
  1248. X#else
  1249. Xmain()
  1250. X{
  1251. X    fputs("This system does not support hashed database files\n", stderr);
  1252. X    exit(0);
  1253. X}
  1254. X#endif
  1255. END_OF_FILE
  1256. if test 6603 -ne `wc -c <'mk-amd-map.c'`; then
  1257.     echo shar: \"'mk-amd-map.c'\" unpacked with wrong size!
  1258. fi
  1259. # end of 'mk-amd-map.c'
  1260. fi
  1261. if test -f 'mntfs.c' -a "${1}" != "-c" ; then 
  1262.   echo shar: Will not clobber existing file \"'mntfs.c'\"
  1263. else
  1264. echo shar: Extracting \"'mntfs.c'\" \(6936 characters\)
  1265. sed "s/^X//" >'mntfs.c' <<'END_OF_FILE'
  1266. X/*
  1267. X * $Id: mntfs.c,v 5.1.1.3 90/01/11 17:10:07 jsp Exp Locker: jsp $
  1268. X *
  1269. X * Copyright (c) 1990 Jan-Simon Pendry
  1270. X * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  1271. X * Copyright (c) 1990 The Regents of the University of California.
  1272. X * All rights reserved.
  1273. X *
  1274. X * This code is derived from software contributed to Berkeley by
  1275. X * Jan-Simon Pendry at Imperial College, London.
  1276. X *
  1277. X * Redistribution and use in source and binary forms are permitted
  1278. X * provided that the above copyright notice and this paragraph are
  1279. X * duplicated in all such forms and that any documentation,
  1280. X * advertising materials, and other materials related to such
  1281. X * distribution and use acknowledge that the software was developed
  1282. X * by Imperial College of Science, Technology and Medicine, London, UK.
  1283. X * The names of the College and University may not be used to endorse
  1284. X * or promote products derived from this software without specific
  1285. X * prior written permission.
  1286. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1287. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1288. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1289. X *
  1290. X *    %W% (Berkeley) %G%
  1291. X */
  1292. X
  1293. X#include "am.h"
  1294. X
  1295. Xextern qelem mfhead;
  1296. Xqelem mfhead = { &mfhead, &mfhead };
  1297. X
  1298. Xint mntfs_allocated;
  1299. X
  1300. X/*
  1301. X * This is the default attributes field which
  1302. X * is copied into every new node to be created.
  1303. X * The individual filesystem fs_init() routines
  1304. X * patch the copy to represent the particular
  1305. X * details for the relevant filesystem type
  1306. X */
  1307. Xstatic struct fattr gen_fattr = {
  1308. X    NFDIR,                /* type */
  1309. X    NFSMODE_DIR | 0555,        /* mode */
  1310. X    2,                /* nlink */
  1311. X    0,                /* uid */
  1312. X    0,                /* gid */
  1313. X    512,                /* size */
  1314. X    4096,                /* blocksize */
  1315. X    0,                /* rdev */
  1316. X    1,                /* blocks */
  1317. X    0,                /* fsid */
  1318. X    0,                /* fileid */
  1319. X    { 0, 0 },            /* atime */
  1320. X    { 0, 0 },            /* mtime */
  1321. X    { 0, 0 },            /* ctime */
  1322. X};
  1323. X
  1324. Xmntfs *dup_mntfs(mf)
  1325. Xmntfs *mf;
  1326. X{
  1327. X    if (mf->mf_refc == 0) {
  1328. X        untimeout(mf->mf_cid);
  1329. X        mf->mf_cid = 0;
  1330. X        mf->mf_error = -1;
  1331. X        mf->mf_error &= ~MFF_ERROR;
  1332. X    }
  1333. X    mf->mf_refc++;
  1334. X    return mf;
  1335. X}
  1336. X
  1337. Xstatic init_mntfs(mf, ops, mo, mp, info, opts)
  1338. Xmntfs *mf;
  1339. Xam_ops *ops;
  1340. Xam_opts *mo;
  1341. Xchar *mp;
  1342. Xchar *info;
  1343. Xchar *opts;
  1344. X{
  1345. X    mf->mf_ops = ops;
  1346. X    mf->mf_fo = mo;
  1347. X    mf->mf_mount = strdup(mp);
  1348. X    mf->mf_info = strdup(info);
  1349. X    mf->mf_opts = strdup(opts);
  1350. X    mf->mf_refc = 1;
  1351. X    mf->mf_flags = 0;
  1352. X    mf->mf_error = -1;
  1353. X    mf->mf_cid = 0;
  1354. X    mf->mf_private = 0;
  1355. X    mf->mf_prfree = 0;
  1356. X    mf->mf_attr.status = NFS_OK;
  1357. X    mf->mf_fattr = gen_fattr;
  1358. X    mf->mf_fattr.fsid = 42;
  1359. X    mf->mf_fattr.fileid = 0;
  1360. X    mf->mf_fattr.atime.seconds = clocktime();
  1361. X    mf->mf_fattr.atime.useconds = 0;
  1362. X    mf->mf_fattr.mtime = mf->mf_fattr.ctime = mf->mf_fattr.atime;
  1363. X
  1364. X    if (ops->ffserver)
  1365. X        mf->mf_server = (*ops->ffserver)(mf);
  1366. X    else
  1367. X        mf->mf_server = 0;
  1368. X}
  1369. X
  1370. Xstatic mntfs *alloc_mntfs(ops, mo, mp, info, opts)
  1371. Xam_ops *ops;
  1372. Xam_opts *mo;
  1373. Xchar *mp;
  1374. Xchar *info;
  1375. Xchar *opts;
  1376. X{
  1377. X    mntfs *mf = ALLOC(mntfs);
  1378. X    init_mntfs(mf, ops, mo, mp, info, opts);
  1379. X    ins_que(&mf->mf_q, &mfhead);
  1380. X    mntfs_allocated++;
  1381. X
  1382. X    return mf;
  1383. X}
  1384. X
  1385. Xmntfs *find_mntfs(ops, mo, mp, info, opts)
  1386. Xam_ops *ops;
  1387. Xam_opts *mo;
  1388. Xchar *mp;
  1389. Xchar *info;
  1390. Xchar *opts;
  1391. X{
  1392. X    mntfs *mf;
  1393. X
  1394. X#ifdef DEBUG
  1395. X    dlog("Locating mntfs reference to %s", mp);
  1396. X#endif
  1397. X    ITER(mf, mntfs, &mfhead) {
  1398. X        if (STREQ(mf->mf_mount, mp)) {
  1399. X            /*
  1400. X             * Handle cases where error ops are involved
  1401. X             */
  1402. X            if (ops == &efs_ops) {
  1403. X                /*
  1404. X                 * If the existing ops are not efs_ops
  1405. X                 * then continue...
  1406. X                 */
  1407. X                if (mf->mf_ops != &efs_ops)
  1408. X                    continue;
  1409. X            } else /* ops != &efs_ops */ {
  1410. X                /*
  1411. X                 * If the existing ops are efs_ops
  1412. X                 * then continue...
  1413. X                 */
  1414. X                if (mf->mf_ops == &efs_ops)
  1415. X                    continue;
  1416. X            }
  1417. X
  1418. X            if ((mf->mf_flags & MFF_RESTART) && amd_state == Run) {
  1419. X                /*
  1420. X                 * Restart a previously mounted filesystem.
  1421. X                 */
  1422. X                mntfs *mf2 = alloc_mntfs(&ifs_ops, mo, mp, info, opts);
  1423. X#ifdef DEBUG
  1424. X                dlog("Restarting filesystem %s", mf->mf_mount);
  1425. X#endif
  1426. X                /*
  1427. X                 * Remember who we are restarting
  1428. X                 */
  1429. X                mf2->mf_private = (voidp) dup_mntfs(mf);
  1430. X                mf2->mf_prfree = free_mntfs;
  1431. X                return mf2;
  1432. X            }
  1433. X            mf->mf_fo = mo;
  1434. X            if (!(mf->mf_flags & (MFF_MOUNTED|MFF_MOUNTING|MFF_UNMOUNTING))) {
  1435. X                fserver *fs;
  1436. X                mf->mf_opts = strealloc(mf->mf_opts, opts);
  1437. X                mf->mf_info = strealloc(mf->mf_info, info);
  1438. X                fs = ops->ffserver ? (*ops->ffserver)(mf) : (fserver *) 0;
  1439. X                if (mf->mf_server)
  1440. X                    free_srvr(mf->mf_server);
  1441. X                mf->mf_server = fs;
  1442. X            }
  1443. X            return dup_mntfs(mf);
  1444. X        }
  1445. X    }
  1446. X
  1447. X    return alloc_mntfs(ops, mo, mp, info, opts);
  1448. X}
  1449. X
  1450. Xmntfs *new_mntfs()
  1451. X{
  1452. X    return alloc_mntfs(&efs_ops, (am_opts *) 0, "//nil//", ".", "");
  1453. X}
  1454. X
  1455. Xstatic void uninit_mntfs(mf, rmd)
  1456. Xmntfs *mf;
  1457. Xint rmd;
  1458. X{
  1459. X    if (mf->mf_mount) free((voidp) mf->mf_mount);
  1460. X    if (mf->mf_opts) free((voidp) mf->mf_opts);
  1461. X    if (mf->mf_info) free((voidp) mf->mf_info);
  1462. X    if (mf->mf_private && mf->mf_prfree)
  1463. X        (*mf->mf_prfree)(mf->mf_private);
  1464. X    /*
  1465. X     * Clean up any directories that were made
  1466. X     */
  1467. X    if (rmd && (mf->mf_flags & MFF_MKMNT))
  1468. X        rmdirs(mf->mf_mount);
  1469. X
  1470. X    /*
  1471. X     * Clean up the file server
  1472. X     */
  1473. X    if (mf->mf_server)
  1474. X        free_srvr(mf->mf_server);
  1475. X
  1476. X    /*
  1477. X     * Don't do a callback on this mount
  1478. X     */
  1479. X    if (mf->mf_cid) {
  1480. X        untimeout(mf->mf_cid);
  1481. X        mf->mf_cid = 0;
  1482. X    }
  1483. X}
  1484. X
  1485. Xstatic void discard_mntfs(mf)
  1486. Xmntfs *mf;
  1487. X{
  1488. X    rem_que(&mf->mf_q);
  1489. X    /*
  1490. X     * Free memory
  1491. X     */
  1492. X    uninit_mntfs(mf, TRUE);
  1493. X    free((voidp) mf);
  1494. X
  1495. X    --mntfs_allocated;
  1496. X}
  1497. X
  1498. Xvoid flush_mntfs()
  1499. X{
  1500. X    mntfs *mf;
  1501. X
  1502. X    mf = FIRST(mntfs, &mfhead);
  1503. X    while (mf != HEAD(mntfs, &mfhead)) {
  1504. X        mntfs *mf2 = mf;
  1505. X        mf = NEXT(mntfs, mf);
  1506. X        if (mf2->mf_refc == 0 && mf2->mf_cid)
  1507. X            discard_mntfs(mf2);
  1508. X    }
  1509. X}
  1510. X
  1511. Xvoid free_mntfs(mf)
  1512. Xmntfs *mf;
  1513. X{
  1514. X    if (--mf->mf_refc == 0) {
  1515. X        if (mf->mf_flags & MFF_MOUNTED) {
  1516. X            int quoted;
  1517. X            mf->mf_flags &= ~MFF_MOUNTED;
  1518. X
  1519. X            /*
  1520. X             * Record for posterity
  1521. X             */
  1522. X            quoted = strchr(mf->mf_info, ' ') != 0;    /* cheap */
  1523. X            plog(XLOG_INFO, "%s%s%s %sed fstype %s from %s",
  1524. X                quoted ? "\"" : "",
  1525. X                mf->mf_info,
  1526. X                quoted ? "\"" : "",
  1527. X                mf->mf_error ? "discard" : "unmount",
  1528. X                mf->mf_ops->fs_type, mf->mf_mount);
  1529. X        }
  1530. X
  1531. X        if (mf->mf_ops->fs_flags & FS_DISCARD) {
  1532. X#ifdef DEBUG
  1533. X            dlog("Immediately discarding mntfs for %s", mf->mf_mount);
  1534. X#endif
  1535. X            discard_mntfs(mf);
  1536. X        } else {
  1537. X#ifdef DEBUG
  1538. X            if (mf->mf_flags & MFF_RESTART) {
  1539. X                dlog("Discarding remount hook for %s", mf->mf_mount);
  1540. X            } else {
  1541. X                dlog("Discarding last mntfs reference to %s fstype %s",
  1542. X                    mf->mf_mount, mf->mf_ops->fs_type);
  1543. X            }
  1544. X            if (mf->mf_flags & (MFF_MOUNTED|MFF_MOUNTING|MFF_UNMOUNTING))
  1545. X                dlog("mntfs reference for %s still active", mf->mf_mount);
  1546. X#endif
  1547. X            mf->mf_cid = timeout(ALLOWED_MOUNT_TIME, discard_mntfs, (voidp) mf);
  1548. X        }
  1549. X    }
  1550. X}
  1551. X
  1552. Xmntfs *realloc_mntfs(mf, ops, mo, mp, info, opts)
  1553. Xmntfs *mf;
  1554. Xam_ops *ops;
  1555. Xam_opts *mo;
  1556. Xchar *mp;
  1557. Xchar *info;
  1558. Xchar *opts;
  1559. X{
  1560. X    mntfs *mf2;
  1561. X    if (mf->mf_refc == 1 && mf->mf_ops == &ifs_ops && STREQ(mf->mf_mount, mp)) {
  1562. X        /*
  1563. X         * If we are inheriting then just return
  1564. X         * the same node...
  1565. X         */
  1566. X        return mf;
  1567. X    }
  1568. X    mf2 = find_mntfs(ops, mo, mp, info, opts);
  1569. X    free_mntfs(mf);
  1570. X    return mf2;
  1571. X}
  1572. END_OF_FILE
  1573. if test 6936 -ne `wc -c <'mntfs.c'`; then
  1574.     echo shar: \"'mntfs.c'\" unpacked with wrong size!
  1575. fi
  1576. # end of 'mntfs.c'
  1577. fi
  1578. if test -f 'nfs_prot.h' -a "${1}" != "-c" ; then 
  1579.   echo shar: Will not clobber existing file \"'nfs_prot.h'\"
  1580. else
  1581. echo shar: Extracting \"'nfs_prot.h'\" \(6142 characters\)
  1582. sed "s/^X//" >'nfs_prot.h' <<'END_OF_FILE'
  1583. X/* $Id: nfs_prot.h,v 5.1 89/11/17 18:21:14 jsp Exp Locker: jsp $ */
  1584. X
  1585. X#define    xdr_nfsstat xdr_enum
  1586. X#define    xdr_ftype xdr_enum
  1587. X
  1588. X#define NFS_PORT 2049
  1589. X#define NFS_MAXDATA 8192
  1590. X#define NFS_MAXPATHLEN 1024
  1591. X#define NFS_MAXNAMLEN 255
  1592. X#define NFS_FHSIZE 32
  1593. X#define NFS_COOKIESIZE 4
  1594. X#define NFS_FIFO_DEV -1
  1595. X#define NFSMODE_FMT 0170000
  1596. X#define NFSMODE_DIR 0040000
  1597. X#define NFSMODE_CHR 0020000
  1598. X#define NFSMODE_BLK 0060000
  1599. X#define NFSMODE_REG 0100000
  1600. X#define NFSMODE_LNK 0120000
  1601. X#define NFSMODE_SOCK 0140000
  1602. X#define NFSMODE_FIFO 0010000
  1603. X
  1604. Xenum nfsstat {
  1605. X    NFS_OK = 0,
  1606. X    NFSERR_PERM = 1,
  1607. X    NFSERR_NOENT = 2,
  1608. X    NFSERR_IO = 5,
  1609. X    NFSERR_NXIO = 6,
  1610. X    NFSERR_ACCES = 13,
  1611. X    NFSERR_EXIST = 17,
  1612. X    NFSERR_NODEV = 19,
  1613. X    NFSERR_NOTDIR = 20,
  1614. X    NFSERR_ISDIR = 21,
  1615. X    NFSERR_FBIG = 27,
  1616. X    NFSERR_NOSPC = 28,
  1617. X    NFSERR_ROFS = 30,
  1618. X    NFSERR_NAMETOOLONG = 63,
  1619. X    NFSERR_NOTEMPTY = 66,
  1620. X    NFSERR_DQUOT = 69,
  1621. X    NFSERR_STALE = 70,
  1622. X    NFSERR_WFLUSH = 99
  1623. X};
  1624. Xtypedef enum nfsstat nfsstat;
  1625. Xbool_t xdr_nfsstat();
  1626. X
  1627. X
  1628. Xenum ftype {
  1629. X    NFNON = 0,
  1630. X    NFREG = 1,
  1631. X    NFDIR = 2,
  1632. X    NFBLK = 3,
  1633. X    NFCHR = 4,
  1634. X    NFLNK = 5,
  1635. X    NFSOCK = 6,
  1636. X    NFBAD = 7,
  1637. X    NFFIFO = 8
  1638. X};
  1639. Xtypedef enum ftype ftype;
  1640. X/* static bool_t xdr_ftype(); */
  1641. X
  1642. X
  1643. Xstruct nfs_fh {
  1644. X    char data[NFS_FHSIZE];
  1645. X};
  1646. Xtypedef struct nfs_fh nfs_fh;
  1647. Xbool_t xdr_nfs_fh();
  1648. X
  1649. X
  1650. Xstruct nfstime {
  1651. X    u_int seconds;
  1652. X    u_int useconds;
  1653. X};
  1654. Xtypedef struct nfstime nfstime;
  1655. X/* static bool_t xdr_nfstime(); */
  1656. X
  1657. X
  1658. Xstruct fattr {
  1659. X    ftype type;
  1660. X    u_int mode;
  1661. X    u_int nlink;
  1662. X    u_int uid;
  1663. X    u_int gid;
  1664. X    u_int size;
  1665. X    u_int blocksize;
  1666. X    u_int rdev;
  1667. X    u_int blocks;
  1668. X    u_int fsid;
  1669. X    u_int fileid;
  1670. X    nfstime atime;
  1671. X    nfstime mtime;
  1672. X    nfstime ctime;
  1673. X};
  1674. Xtypedef struct fattr fattr;
  1675. X/* static bool_t xdr_fattr(); */
  1676. X
  1677. X
  1678. Xstruct sattr {
  1679. X    u_int mode;
  1680. X    u_int uid;
  1681. X    u_int gid;
  1682. X    u_int size;
  1683. X    nfstime atime;
  1684. X    nfstime mtime;
  1685. X};
  1686. Xtypedef struct sattr sattr;
  1687. X/* static bool_t xdr_sattr(); */
  1688. X
  1689. X
  1690. Xtypedef char *filename;
  1691. X/* static bool_t xdr_filename(); */
  1692. X
  1693. X
  1694. Xtypedef char *nfspath;
  1695. Xbool_t xdr_nfspath();
  1696. X
  1697. X
  1698. Xstruct attrstat {
  1699. X    nfsstat status;
  1700. X    union {
  1701. X        fattr attributes;
  1702. X    } attrstat_u;
  1703. X};
  1704. Xtypedef struct attrstat attrstat;
  1705. Xbool_t xdr_attrstat();
  1706. X
  1707. X
  1708. Xstruct sattrargs {
  1709. X    nfs_fh file;
  1710. X    sattr attributes;
  1711. X};
  1712. Xtypedef struct sattrargs sattrargs;
  1713. Xbool_t xdr_sattrargs();
  1714. X
  1715. X
  1716. Xstruct diropargs {
  1717. X    nfs_fh dir;
  1718. X    filename name;
  1719. X};
  1720. Xtypedef struct diropargs diropargs;
  1721. Xbool_t xdr_diropargs();
  1722. X
  1723. X
  1724. Xstruct diropokres {
  1725. X    nfs_fh file;
  1726. X    fattr attributes;
  1727. X};
  1728. Xtypedef struct diropokres diropokres;
  1729. Xbool_t xdr_diropokres();
  1730. X
  1731. X
  1732. Xstruct diropres {
  1733. X    nfsstat status;
  1734. X    union {
  1735. X        diropokres diropres;
  1736. X    } diropres_u;
  1737. X};
  1738. Xtypedef struct diropres diropres;
  1739. Xbool_t xdr_diropres();
  1740. X
  1741. X
  1742. Xstruct readlinkres {
  1743. X    nfsstat status;
  1744. X    union {
  1745. X        nfspath data;
  1746. X    } readlinkres_u;
  1747. X};
  1748. Xtypedef struct readlinkres readlinkres;
  1749. Xbool_t xdr_readlinkres();
  1750. X
  1751. X
  1752. Xstruct readargs {
  1753. X    nfs_fh file;
  1754. X    u_int offset;
  1755. X    u_int count;
  1756. X    u_int totalcount;
  1757. X};
  1758. Xtypedef struct readargs readargs;
  1759. Xbool_t xdr_readargs();
  1760. X
  1761. X
  1762. Xstruct readokres {
  1763. X    fattr attributes;
  1764. X    struct {
  1765. X        u_int data_len;
  1766. X        char *data_val;
  1767. X    } data;
  1768. X};
  1769. Xtypedef struct readokres readokres;
  1770. Xbool_t xdr_readokres();
  1771. X
  1772. X
  1773. Xstruct readres {
  1774. X    nfsstat status;
  1775. X    union {
  1776. X        readokres reply;
  1777. X    } readres_u;
  1778. X};
  1779. Xtypedef struct readres readres;
  1780. Xbool_t xdr_readres();
  1781. X
  1782. X
  1783. Xstruct writeargs {
  1784. X    nfs_fh file;
  1785. X    u_int beginoffset;
  1786. X    u_int offset;
  1787. X    u_int totalcount;
  1788. X    struct {
  1789. X        u_int data_len;
  1790. X        char *data_val;
  1791. X    } data;
  1792. X};
  1793. Xtypedef struct writeargs writeargs;
  1794. Xbool_t xdr_writeargs();
  1795. X
  1796. X
  1797. Xstruct createargs {
  1798. X    diropargs where;
  1799. X    sattr attributes;
  1800. X};
  1801. Xtypedef struct createargs createargs;
  1802. Xbool_t xdr_createargs();
  1803. X
  1804. X
  1805. Xstruct renameargs {
  1806. X    diropargs from;
  1807. X    diropargs to;
  1808. X};
  1809. Xtypedef struct renameargs renameargs;
  1810. Xbool_t xdr_renameargs();
  1811. X
  1812. X
  1813. Xstruct linkargs {
  1814. X    nfs_fh from;
  1815. X    diropargs to;
  1816. X};
  1817. Xtypedef struct linkargs linkargs;
  1818. Xbool_t xdr_linkargs();
  1819. X
  1820. X
  1821. Xstruct symlinkargs {
  1822. X    diropargs from;
  1823. X    nfspath to;
  1824. X    sattr attributes;
  1825. X};
  1826. Xtypedef struct symlinkargs symlinkargs;
  1827. Xbool_t xdr_symlinkargs();
  1828. X
  1829. X
  1830. Xtypedef char nfscookie[NFS_COOKIESIZE];
  1831. X/* static bool_t xdr_nfscookie(); */
  1832. X
  1833. X
  1834. Xstruct readdirargs {
  1835. X    nfs_fh dir;
  1836. X    nfscookie cookie;
  1837. X    u_int count;
  1838. X};
  1839. Xtypedef struct readdirargs readdirargs;
  1840. Xbool_t xdr_readdirargs();
  1841. X
  1842. X
  1843. Xstruct entry {
  1844. X    u_int fileid;
  1845. X    filename name;
  1846. X    nfscookie cookie;
  1847. X    struct entry *nextentry;
  1848. X};
  1849. Xtypedef struct entry entry;
  1850. X/* static bool_t xdr_entry(); */
  1851. X
  1852. X
  1853. Xstruct dirlist {
  1854. X    entry *entries;
  1855. X    bool_t eof;
  1856. X};
  1857. Xtypedef struct dirlist dirlist;
  1858. X/* static bool_t xdr_dirlist(); */
  1859. X
  1860. X
  1861. Xstruct readdirres {
  1862. X    nfsstat status;
  1863. X    union {
  1864. X        dirlist reply;
  1865. X    } readdirres_u;
  1866. X};
  1867. Xtypedef struct readdirres readdirres;
  1868. Xbool_t xdr_readdirres();
  1869. X
  1870. X
  1871. Xstruct statfsokres {
  1872. X    u_int tsize;
  1873. X    u_int bsize;
  1874. X    u_int blocks;
  1875. X    u_int bfree;
  1876. X    u_int bavail;
  1877. X};
  1878. Xtypedef struct statfsokres statfsokres;
  1879. Xbool_t xdr_statfsokres();
  1880. X
  1881. X
  1882. Xstruct statfsres {
  1883. X    nfsstat status;
  1884. X    union {
  1885. X        statfsokres reply;
  1886. X    } statfsres_u;
  1887. X};
  1888. Xtypedef struct statfsres statfsres;
  1889. Xbool_t xdr_statfsres();
  1890. X
  1891. X
  1892. X#define NFS_PROGRAM ((u_long)100003)
  1893. X#define NFS_VERSION ((u_long)2)
  1894. X#define NFSPROC_NULL ((u_long)0)
  1895. Xextern voidp nfsproc_null_2();
  1896. X#define NFSPROC_GETATTR ((u_long)1)
  1897. Xextern attrstat *nfsproc_getattr_2();
  1898. X#define NFSPROC_SETATTR ((u_long)2)
  1899. Xextern attrstat *nfsproc_setattr_2();
  1900. X#define NFSPROC_ROOT ((u_long)3)
  1901. Xextern voidp nfsproc_root_2();
  1902. X#define NFSPROC_LOOKUP ((u_long)4)
  1903. Xextern diropres *nfsproc_lookup_2();
  1904. X#define NFSPROC_READLINK ((u_long)5)
  1905. Xextern readlinkres *nfsproc_readlink_2();
  1906. X#define NFSPROC_READ ((u_long)6)
  1907. Xextern readres *nfsproc_read_2();
  1908. X#define NFSPROC_WRITECACHE ((u_long)7)
  1909. Xextern voidp nfsproc_writecache_2();
  1910. X#define NFSPROC_WRITE ((u_long)8)
  1911. Xextern attrstat *nfsproc_write_2();
  1912. X#define NFSPROC_CREATE ((u_long)9)
  1913. Xextern diropres *nfsproc_create_2();
  1914. X#define NFSPROC_REMOVE ((u_long)10)
  1915. Xextern nfsstat *nfsproc_remove_2();
  1916. X#define NFSPROC_RENAME ((u_long)11)
  1917. Xextern nfsstat *nfsproc_rename_2();
  1918. X#define NFSPROC_LINK ((u_long)12)
  1919. Xextern nfsstat *nfsproc_link_2();
  1920. X#define NFSPROC_SYMLINK ((u_long)13)
  1921. Xextern nfsstat *nfsproc_symlink_2();
  1922. X#define NFSPROC_MKDIR ((u_long)14)
  1923. Xextern diropres *nfsproc_mkdir_2();
  1924. X#define NFSPROC_RMDIR ((u_long)15)
  1925. Xextern nfsstat *nfsproc_rmdir_2();
  1926. X#define NFSPROC_READDIR ((u_long)16)
  1927. Xextern readdirres *nfsproc_readdir_2();
  1928. X#define NFSPROC_STATFS ((u_long)17)
  1929. Xextern statfsres *nfsproc_statfs_2();
  1930. X
  1931. END_OF_FILE
  1932. if test 6142 -ne `wc -c <'nfs_prot.h'`; then
  1933.     echo shar: \"'nfs_prot.h'\" unpacked with wrong size!
  1934. fi
  1935. # end of 'nfs_prot.h'
  1936. fi
  1937. if test -f 'nfs_prot.x' -a "${1}" != "-c" ; then 
  1938.   echo shar: Will not clobber existing file \"'nfs_prot.x'\"
  1939. else
  1940. echo shar: Extracting \"'nfs_prot.x'\" \(6368 characters\)
  1941. sed "s/^X//" >'nfs_prot.x' <<'END_OF_FILE'
  1942. X/*
  1943. X * nfs_prot.x 1.3 88/02/08
  1944. X * Copyright 1987 Sun Microsystems, Inc.
  1945. X */
  1946. Xconst NFS_PORT          = 2049;
  1947. Xconst NFS_MAXDATA       = 8192;
  1948. Xconst NFS_MAXPATHLEN    = 1024;
  1949. Xconst NFS_MAXNAMLEN    = 255;
  1950. Xconst NFS_FHSIZE    = 32;
  1951. Xconst NFS_COOKIESIZE    = 4;
  1952. Xconst NFS_FIFO_DEV    = -1;    /* size kludge for named pipes */
  1953. X
  1954. X/*
  1955. X * File types
  1956. X */
  1957. Xconst NFSMODE_FMT  = 0170000;    /* type of file */
  1958. Xconst NFSMODE_DIR  = 0040000;    /* directory */
  1959. Xconst NFSMODE_CHR  = 0020000;    /* character special */
  1960. Xconst NFSMODE_BLK  = 0060000;    /* block special */
  1961. Xconst NFSMODE_REG  = 0100000;    /* regular */
  1962. Xconst NFSMODE_LNK  = 0120000;    /* symbolic link */
  1963. Xconst NFSMODE_SOCK = 0140000;    /* socket */
  1964. Xconst NFSMODE_FIFO = 0010000;    /* fifo */
  1965. X
  1966. X/*
  1967. X * Error status
  1968. X */
  1969. Xenum nfsstat {
  1970. X    NFS_OK= 0,        /* no error */
  1971. X    NFSERR_PERM=1,        /* Not owner */
  1972. X    NFSERR_NOENT=2,        /* No such file or directory */
  1973. X    NFSERR_IO=5,        /* I/O error */
  1974. X    NFSERR_NXIO=6,        /* No such device or address */
  1975. X    NFSERR_ACCES=13,    /* Permission denied */
  1976. X    NFSERR_EXIST=17,    /* File exists */
  1977. X    NFSERR_NODEV=19,    /* No such device */
  1978. X    NFSERR_NOTDIR=20,    /* Not a directory*/
  1979. X    NFSERR_ISDIR=21,    /* Is a directory */
  1980. X    NFSERR_FBIG=27,        /* File too large */
  1981. X    NFSERR_NOSPC=28,    /* No space left on device */
  1982. X    NFSERR_ROFS=30,        /* Read-only file system */
  1983. X    NFSERR_NAMETOOLONG=63,    /* File name too long */
  1984. X    NFSERR_NOTEMPTY=66,    /* Directory not empty */
  1985. X    NFSERR_DQUOT=69,    /* Disc quota exceeded */
  1986. X    NFSERR_STALE=70,    /* Stale NFS file handle */
  1987. X    NFSERR_WFLUSH=99    /* write cache flushed */
  1988. X};
  1989. X
  1990. X/*
  1991. X * File types
  1992. X */
  1993. Xenum ftype {
  1994. X    NFNON = 0,    /* non-file */
  1995. X    NFREG = 1,    /* regular file */
  1996. X    NFDIR = 2,    /* directory */
  1997. X    NFBLK = 3,    /* block special */
  1998. X    NFCHR = 4,    /* character special */
  1999. X    NFLNK = 5,    /* symbolic link */
  2000. X    NFSOCK = 6,    /* unix domain sockets */
  2001. X    NFBAD = 7,    /* unused */
  2002. X    NFFIFO = 8     /* named pipe */
  2003. X};
  2004. X
  2005. X/*
  2006. X * File access handle
  2007. X */
  2008. Xstruct nfs_fh {
  2009. X    opaque data[NFS_FHSIZE];
  2010. X};
  2011. X
  2012. X/* 
  2013. X * Timeval
  2014. X */
  2015. Xstruct nfstime {
  2016. X    unsigned seconds;
  2017. X    unsigned useconds;
  2018. X};
  2019. X
  2020. X
  2021. X/*
  2022. X * File attributes
  2023. X */
  2024. Xstruct fattr {
  2025. X    ftype type;        /* file type */
  2026. X    unsigned mode;        /* protection mode bits */
  2027. X    unsigned nlink;        /* # hard links */
  2028. X    unsigned uid;        /* owner user id */
  2029. X    unsigned gid;        /* owner group id */
  2030. X    unsigned size;        /* file size in bytes */
  2031. X    unsigned blocksize;    /* prefered block size */
  2032. X    unsigned rdev;        /* special device # */
  2033. X    unsigned blocks;    /* Kb of disk used by file */
  2034. X    unsigned fsid;        /* device # */
  2035. X    unsigned fileid;    /* inode # */
  2036. X    nfstime    atime;        /* time of last access */
  2037. X    nfstime    mtime;        /* time of last modification */
  2038. X    nfstime    ctime;        /* time of last change */
  2039. X};
  2040. X
  2041. X/*
  2042. X * File attributes which can be set
  2043. X */
  2044. Xstruct sattr {
  2045. X    unsigned mode;    /* protection mode bits */
  2046. X    unsigned uid;    /* owner user id */
  2047. X    unsigned gid;    /* owner group id */
  2048. X    unsigned size;    /* file size in bytes */
  2049. X    nfstime    atime;    /* time of last access */
  2050. X    nfstime    mtime;    /* time of last modification */
  2051. X};
  2052. X
  2053. X
  2054. Xtypedef string filename<NFS_MAXNAMLEN>; 
  2055. Xtypedef string nfspath<NFS_MAXPATHLEN>;
  2056. X
  2057. X/*
  2058. X * Reply status with file attributes
  2059. X */
  2060. Xunion attrstat switch (nfsstat status) {
  2061. Xcase NFS_OK:
  2062. X    fattr attributes;
  2063. Xdefault:
  2064. X    void;
  2065. X};
  2066. X
  2067. Xstruct sattrargs {
  2068. X    nfs_fh file;
  2069. X    sattr attributes;
  2070. X};
  2071. X
  2072. X/*
  2073. X * Arguments for directory operations
  2074. X */
  2075. Xstruct diropargs {
  2076. X    nfs_fh    dir;    /* directory file handle */
  2077. X    filename name;        /* name (up to NFS_MAXNAMLEN bytes) */
  2078. X};
  2079. X
  2080. Xstruct diropokres {
  2081. X    nfs_fh file;
  2082. X    fattr attributes;
  2083. X};
  2084. X
  2085. X/*
  2086. X * Results from directory operation
  2087. X */
  2088. Xunion diropres switch (nfsstat status) {
  2089. Xcase NFS_OK:
  2090. X    diropokres diropres;
  2091. Xdefault:
  2092. X    void;
  2093. X};
  2094. X
  2095. Xunion readlinkres switch (nfsstat status) {
  2096. Xcase NFS_OK:
  2097. X    nfspath data;
  2098. Xdefault:
  2099. X    void;
  2100. X};
  2101. X
  2102. X/*
  2103. X * Arguments to remote read
  2104. X */
  2105. Xstruct readargs {
  2106. X    nfs_fh file;        /* handle for file */
  2107. X    unsigned offset;    /* byte offset in file */
  2108. X    unsigned count;        /* immediate read count */
  2109. X    unsigned totalcount;    /* total read count (from this offset)*/
  2110. X};
  2111. X
  2112. X/*
  2113. X * Status OK portion of remote read reply
  2114. X */
  2115. Xstruct readokres {
  2116. X    fattr    attributes;    /* attributes, need for pagin*/
  2117. X    opaque data<NFS_MAXDATA>;
  2118. X};
  2119. X
  2120. Xunion readres switch (nfsstat status) {
  2121. Xcase NFS_OK:
  2122. X    readokres reply;
  2123. Xdefault:
  2124. X    void;
  2125. X};
  2126. X
  2127. X/*
  2128. X * Arguments to remote write 
  2129. X */
  2130. Xstruct writeargs {
  2131. X    nfs_fh    file;        /* handle for file */
  2132. X    unsigned beginoffset;    /* beginning byte offset in file */
  2133. X    unsigned offset;    /* current byte offset in file */
  2134. X    unsigned totalcount;    /* total write count (to this offset)*/
  2135. X    opaque data<NFS_MAXDATA>;
  2136. X};
  2137. X
  2138. Xstruct createargs {
  2139. X    diropargs where;
  2140. X    sattr attributes;
  2141. X};
  2142. X
  2143. Xstruct renameargs {
  2144. X    diropargs from;
  2145. X    diropargs to;
  2146. X};
  2147. X
  2148. Xstruct linkargs {
  2149. X    nfs_fh from;
  2150. X    diropargs to;
  2151. X};
  2152. X
  2153. Xstruct symlinkargs {
  2154. X    diropargs from;
  2155. X    nfspath to;
  2156. X    sattr attributes;
  2157. X};
  2158. X
  2159. X
  2160. Xtypedef opaque nfscookie[NFS_COOKIESIZE];
  2161. X
  2162. X/*
  2163. X * Arguments to readdir
  2164. X */
  2165. Xstruct readdirargs {
  2166. X    nfs_fh dir;        /* directory handle */
  2167. X    nfscookie cookie;
  2168. X    unsigned count;        /* number of directory bytes to read */
  2169. X};
  2170. X
  2171. Xstruct entry {
  2172. X    unsigned fileid;
  2173. X    filename name;
  2174. X    nfscookie cookie;
  2175. X    entry *nextentry;
  2176. X};
  2177. X
  2178. Xstruct dirlist {
  2179. X    entry *entries;
  2180. X    bool eof;
  2181. X};
  2182. X
  2183. Xunion readdirres switch (nfsstat status) {
  2184. Xcase NFS_OK:
  2185. X    dirlist reply;
  2186. Xdefault:
  2187. X    void;
  2188. X};
  2189. X
  2190. Xstruct statfsokres {
  2191. X    unsigned tsize;    /* preferred transfer size in bytes */
  2192. X    unsigned bsize;    /* fundamental file system block size */
  2193. X    unsigned blocks;    /* total blocks in file system */
  2194. X    unsigned bfree;    /* free blocks in fs */
  2195. X    unsigned bavail;    /* free blocks avail to non-superuser */
  2196. X};
  2197. X
  2198. Xunion statfsres switch (nfsstat status) {
  2199. Xcase NFS_OK:
  2200. X    statfsokres reply;
  2201. Xdefault:
  2202. X    void;
  2203. X};
  2204. X
  2205. X/*
  2206. X * Remote file service routines
  2207. X */
  2208. Xprogram NFS_PROGRAM {
  2209. X    version NFS_VERSION {
  2210. X        void 
  2211. X        NFSPROC_NULL(void) = 0;
  2212. X
  2213. X        attrstat 
  2214. X        NFSPROC_GETATTR(nfs_fh) =    1;
  2215. X
  2216. X        attrstat 
  2217. X        NFSPROC_SETATTR(sattrargs) = 2;
  2218. X
  2219. X        void 
  2220. X        NFSPROC_ROOT(void) = 3;
  2221. X
  2222. X        diropres 
  2223. X        NFSPROC_LOOKUP(diropargs) = 4;
  2224. X
  2225. X        readlinkres 
  2226. X        NFSPROC_READLINK(nfs_fh) = 5;
  2227. X
  2228. X        readres 
  2229. X        NFSPROC_READ(readargs) = 6;
  2230. X
  2231. X        void 
  2232. X        NFSPROC_WRITECACHE(void) = 7;
  2233. X
  2234. X        attrstat
  2235. X        NFSPROC_WRITE(writeargs) = 8;
  2236. X
  2237. X        diropres
  2238. X        NFSPROC_CREATE(createargs) = 9;
  2239. X
  2240. X        nfsstat
  2241. X        NFSPROC_REMOVE(diropargs) = 10;
  2242. X
  2243. X        nfsstat
  2244. X        NFSPROC_RENAME(renameargs) = 11;
  2245. X
  2246. X        nfsstat
  2247. X        NFSPROC_LINK(linkargs) = 12;
  2248. X
  2249. X        nfsstat
  2250. X        NFSPROC_SYMLINK(symlinkargs) = 13;
  2251. X
  2252. X        diropres
  2253. X        NFSPROC_MKDIR(createargs) = 14;
  2254. X
  2255. X        nfsstat
  2256. X        NFSPROC_RMDIR(diropargs) = 15;
  2257. X
  2258. X        readdirres
  2259. X        NFSPROC_READDIR(readdirargs) = 16;
  2260. X
  2261. X        statfsres
  2262. X        NFSPROC_STATFS(nfs_fh) = 17;
  2263. X    } = 2;
  2264. X} = 100003;
  2265. X
  2266. END_OF_FILE
  2267. if test 6368 -ne `wc -c <'nfs_prot.x'`; then
  2268.     echo shar: \"'nfs_prot.x'\" unpacked with wrong size!
  2269. fi
  2270. # end of 'nfs_prot.x'
  2271. fi
  2272. echo shar: End of archive 5 \(of 13\).
  2273. cp /dev/null ark5isdone
  2274. MISSING=""
  2275. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  2276.     if test ! -f ark${I}isdone ; then
  2277.     MISSING="${MISSING} ${I}"
  2278.     fi
  2279. done
  2280. if test "${MISSING}" = "" ; then
  2281.     echo You have unpacked all 13 archives.
  2282.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2283. else
  2284.     echo You still need to unpack the following archives:
  2285.     echo "        " ${MISSING}
  2286. fi
  2287. ##  End of shell archive.
  2288. exit 0
  2289. exit 0 # Just in case...
  2290.